/*
	Travis Tarr
	CS362-400
	
	Assignment #3
	
	Testing the buyCard() function
		int buyCard(int supplyPos, struct gameState *state)
		returns -1 when not able to buy
		returns 0 otherwise
*/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

void testBuyCard() {
    int i;
    int seed = 1000;
    int numPlayer = 2;
    int maxBonus = 10;
    int p, r, handCount;
    int bonus;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    int maxHandCount = 5;


    printf ("TESTING buyCard():\n");


	memset(&G, 23, sizeof(struct gameState));   // clear the game state
	r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
	
	G.coins = 8;
	G.numBuys = 1;
	G.supplyCount[1] = 5;
	if(buyCard(1, &G) == 0) {
		printf("testBuyCard(): PASSED when player has enough coins, supply and buys.\n");
	} else {
		printf("testBuyCard(): FAILED when player has enough coins, supply, and buys.\n");
	}
	
	G.coins = 0;
	G.numBuys = 1;
	G.supplyCount[1] = 5;
	if(buyCard(1, &G) == -1) {
		printf("testBuyCard(): PASSED when player has enough supply and buys but not coins.\n");
	} else {
		printf("testBuyCard(): FAILED when player has enough supply and buys but not coins.\n");
	}
	
	G.coins = 8;
	G.numBuys = 0;
	G.supplyCount[1] = 5;
	if(buyCard(1, &G) == -1) {
		printf("testBuyCard(): PASSED when player has enough supply and coins but not buys.\n");
	} else {
		printf("testBuyCard(): FAILED when player has enough supply and coins but not buys.\n");
	}
	
	G.coins = 8;
	G.numBuys = 1;
	G.supplyCount[1] = 0;
	if(buyCard(1, &G) == -1) {
		printf("testBuyCard(): PASSED when player has enough buys and coins but not supply.\n");
	} else {
		printf("testBuyCard(): FAILED when player has enough buys and coins but not supply.\n");
	}
	
}

int main() {
	testBuyCard();
	return 0;
}